import xlwings as xw

import matplotlib.pyplot as plt
import pandas as pd
# 创建excel表
wb = xw.Book("example.xlsx")

# s示例化工作表对象
sht = wb.sheets['Sheet1']

# 在工作表中写入数据
#sht.range('A1').value = [['Foo 1', 'Foo 2', 'Foo 3'], [10.0, 20.0, 30.0]]

df = pd.DataFrame([[1,2],[3,4]], columns=['a','b'])

sht.range('A1').value = df

fig = plt.figure()
plt.plot([1,2,3,4,100])
sht.pictures.add(fig, name='myPlot', update=True)
